package com.example.tester.dao.impl;

import com.example.tester.dao.ISysLogDao;
import com.example.tester.entity.SysLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * sys_log
 */
@Repository
public class SysLogDaoImpl implements ISysLogDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;


    @Override
    public void saveSysLog(SysLog syslog) {
        StringBuffer sql = new StringBuffer("insert into sys_log ");
        sql.append("(request_type,request_url,ip,operation,user_name,cost_time,handle_method,request_params,response,create_time) ");
        sql.append("values(:requestType,:requestUrl,:ip,:operation,");
        sql.append(":userName,:costTime,:handleMethod,:requestParams,:response,:createTime)");

        NamedParameterJdbcTemplate npjt = new NamedParameterJdbcTemplate(this.jdbcTemplate.getDataSource());
        npjt.update(sql.toString(), new BeanPropertySqlParameterSource(syslog));
    }



}
